// Project 5: Lexer Header File
// 4.1.08

enum opcode { BEGIN, END, MOV, ADD, SUB, MULT, DIVD, SWAP, COPY, CLR, GET, DISPR, DISPS, LOOP, COMP, }; 
enum register_t { R0, R1, R2, R3, R4, R5, R6, R7, R8, R9}; 
enum lexeme { CHAR, FLOAT, INTEGER, OPCODE, };  

union value { 
        int i; 
        float f; 
        enum register_t r; 
        enum opcode op; 
        char *ch;
};

struct node {
        union value v; 
        enum lexeme type; 
        struct node *next; 
        struct node *prev;
        int linenum;
};

struct vm_State {
        struct node *head;
        struct node *tail;
		float *regs;
};

/*  ---- lexer.c ----  */

void lex(FILE *err, char s[], int ln, struct vm_State *ll);

void validate(FILE *err, struct vm_State *ll, char t[], int ln);

int isInt(char t[]);

int isFloat(char t[]);

int isReg(char t[]);

int isOp(char t[]);



/*  ---- lexlist.c ----  */

struct vm_State *new_vm ();

void delete_node (struct node *n);

void delete_list (struct vm_State *ll);

void list_pushback (struct vm_State *ll, union value val, int type, int ln);
